New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

promise-debounce

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

promise-debounce

Debounce any promise-returning function so that at any instant only one call is pending

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

promise-debounce

Installation

npm

Get it:

npm install promise-debounce

Require it:

var debounce = require('promise-debounce');

Example

var getStatus = debounce(ajax.bind(null, "GET", "/status.json"));

// The three following calls will cause only a single AJAX request...

getStatus().then(function(status) {
	// ...
});	

getStatus().then(function(status) {
	// ...
});

getStatus().then(function(status) {
	// ...
});

API

var debounced = debounce(fn, [ctx])

Returns a debounced version of fn with optional calling context ctx.

fn must be a function which returns a promise.

If debounced is called and no other call is currently pending, fn will be called and its promise returned. Otherwise - if another call is pending - the original promise will be returned.

Keywords

FAQs

Package last updated on 18 Jun 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc